<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>练习</title>
</head>
<body>
    <script>
        var x = 10
        function Fn() {
            console.log(x)
        }
        function Fn2() {
            var x = 20
            Fn()
        }
        // 输出10
        Fn2()

        var fn = function () {
            console.log(fn)
        }
        // 输出function，没问题，首先会在函数作用域内找fn，找不到，就去全局作用域找，找到fn
        fn()
        var obj = {
            fn2: function () {
                console.log(fn2)
            }
        }
        // 报错，同样现在函数作用域内找fn2；找不到，去全局作用域找，还是找不到，报错
        obj.fn2()
    </script>
</body>
</html>